<div id="footer">
        <?php echo $this->Html->link(
                        $this->Html->image('cake.power.gif', array('border' => '0')),
                        'http://www.cakephp.org/',
                        array('target' => '_blank', 'escape' => false)
                );
        ?>
</div>

<?php echo $this->Javascript->link('../css/bootstrap/js/jquery.js');?>
<?php /*echo $this->Javascript->link('prototype');*/?>
<?php /* echo $this->Javascript->link('chat');*/?>
<?php echo $this->Javascript->link('../css/bootstrap/js/bootstrap');?>
<?php /* echo $this->Javascript->link('../css/bootstrap/js/bootstrap.min');*/?>
<?php echo $this->Javascript->link('../css/bootstrap/js/prettify');?>
<?php /*echo $this->Javascript->link('jquery-1.8.0.min');*/?>
<?php echo $this->Javascript->link('../css/datepicker/js/bootstrap-datepicker');?>
<?php 
    if (($this->params['controller']!="projects")||($this->action!="backlogCard")){
        echo $this->Javascript->link('../css/chosen/chosen.jquery');
    }
?>
 <?php if (($this->params['controller']=="projects")&&(($this->action=="reunion")||($this->action=="retrospective")||($this->action=="planning"))){
// <!--
//Include PubNub from THEIR content delivery netrwork. In the
//documentation, they recommend this as the only way to build
//things appropriately; it allows them to continually update
//the security features.
// 
//NOTE: The PubNub script MUST BE included AFTER the above DIV
//tag that provides the configuration keys.
//-->
    echo '<script type="text/javascript" src="http://cdn.pubnub.com/pubnub-3.1.min.js"></script>';
    echo $this->Javascript->link('projects/'.$this->action);
    echo $this->Javascript->link('projects/'.$this->action.'_chat');
    echo $this->Javascript->link('projects/validation');
    echo $this->Js->writeBuffer(array('cache'=>TRUE)); 
 }
 ?>  
<?php if (($this->params['controller']=="posts")&&($this->action=="add")){
    echo $this->Javascript->link('validation');

    echo $this->Js->writeBuffer(array('cache'=>TRUE)); 
    
    }else {?>
                
 <script type="text/javascript">
    $(".chzn-select").chosen({no_results_text: "No hay coincidencias con"});
    $(".chzn-select-deselect").chosen({allow_single_deselect:true});

    $(document).ready(function() {

        $('.datePicker').datepicker({weekStart: 1});
        $(".alert").alert();

        if(typeof onReady == 'function') {
            //alert('existe onReady');
            onReady();
        }else{
            //alert('no existe onReady');

        }
     });
</script>
<?php } ?>


<!--PAGES -->
<?php if (($this->params['controller']=="pages")&&($this->action=="display")&&($this->params['pass'][0]=="home")){
    echo $this->Javascript->link('../css/colorpicker/js/bootstrap-colorpicker');?>
<script>
        $(document).ready(function(){
                $('#cp1').colorpicker({
                        format: 'hex'
                });
                $('#cp2').colorpicker();
               
                var bodyStyle = $('body')[0].style;
                $('#cp3').colorpicker().on('changeColor', function(ev){
                       bodyStyle.backgroundColor = ev.color.toHex();
                });
                var carStyle = $('#1')[0].style;
                $('#cp4').colorpicker().on('changeColor', function(ev){
                        carStyle.backgroundColor = ev.color.toHex();
                });
                
		
        });
</script>
<?php } ?>
<!--poke-->
<?php if (($this->params['controller']=="projects")&&($this->action=="pokerPlanning")){
 ?>  <script>
    $(document).ready(
        function agregar(story,valor){
            if(confirm("¿Está seguro que desea guardar el tratamiento?"+story+valor)){

                var form = document.getElementById('formTratamiento');
                form.action = '../../../<?php echo $this->uri->segment(1);?>/tratamiento';
                form.submit();
            }
        });
    </script>
<?php 
}?>
    
<?php if (($this->params['controller']=="pages")&&($this->action=="display")&&($this->params['pass'][0]=="about")){?>
    <script type='text/javascript'          
        src='http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js'></script> 
     <script type='text/javascript'          
        src='http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/jquery-ui.js'></script>  
        
     <script>
            $(document).ready(function(){
                    $("#move").draggable({
                        revert: true
                    });
                    $(".item2").draggable({
                        revert: true
                    });
                    $("#trash").droppable({
                        tolerance: 'touch',
                        over: function() {
                            $(this).css('backgroundColor', '#cedae3');
                        },
                        out: function() {
                                $(this).css('backgroundColor', '#a6bcce');
                        },
                        drop: function() {
                                var answer = confirm('Permantly delete this item?');
                                $(this).removeClass('over').addClass('out');
                        }
                    });
            });
    </script>   

<?php } ?>

<!--BACKLOG -->
<?php if (($this->params['controller']=="projects")&&($this->action=="backlogGrid")){?>
    <script type='text/javascript'          
        src='http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js'></script> 
     <script type='text/javascript'          
        src='http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/jquery-ui.js'></script>  
        
     <script>
            $(document).ready(function(){
                    
                    $(".bs-docs-example").draggable({
                        revert: true
                    }).addTouch;
                    
                    $("#estado0").droppable({
<!--                        tolerance: 'touch',-->
                        over: function() {
                            $(this).css('backgroundColor', '#999');
                        },
                        out: function() {
                                $(this).css('backgroundColor', '#1e221e');
                        },
                        drop: function(event, ui) {
                                //var answer = confirm('Permantly delete this item?'+$(ui.draggable).attr("id"));
                               
                                //if(answer){
                                    window.location.href='<?php echo $this->base;?>/stories/change/'+$(ui.draggable).attr("id")+'/0';
                                    
                               // }
                                 $(this).removeClass('over').addClass('out');
                                $(this).css('backgroundColor', '#1e221e');
                        }
                    });
                    $("#estado1").droppable({
                        tolerance: 'touch',
                        over: function() {
                            $(this).css('backgroundColor', '#ffca73');
                        },
                        out: function() {
                                $(this).css('backgroundColor', '#F89406');
                        },
                        drop: function(event, ui) {
                               window.location.href='<?php echo $this->base;?>/stories/change/'+$(ui.draggable).attr("id")+'/1';
                               $(this).removeClass('over').addClass('out');
                               $(this).css('backgroundColor', '#F89406');
                        }
                    });
                    $("#estado2").droppable({
                        tolerance: 'touch',
                        over: function() {
                            $(this).css('backgroundColor', '#cedae3');
                        },
                        out: function() {
                                $(this).css('backgroundColor', '#3A87AD');
                        },
                        drop: function(event, ui) {
                              window.location.href='<?php echo $this->base;?>/stories/change/'+$(ui.draggable).attr("id")+'/2';
                              $(this).removeClass('over').addClass('out');
                              $(this).css('backgroundColor', '#3A87AD');
                        }
                    });
                    $("#estado3").droppable({
                        tolerance: 'touch',
                        over: function() {
                            $(this).css('backgroundColor', '#bcf46c');
                        },
                        out: function() {
                                $(this).css('backgroundColor', '#468847');
                        },
                        drop: function(event, ui) {
                            window.location.href='<?php echo $this->base;?>/stories/change/'+$(ui.draggable).attr("id")+'/3';
                            $(this).removeClass('over').addClass('out');
                            $(this).css('backgroundColor', '#468847');
                        }
                    });
            });
    </script>   

<?php } ?>    
    
<!--PROJECT -->
<?php if (($this->params['controller']=="projects")&&($this->action=="backlogCard")){
    echo $this->Javascript->link('../css/colorpicker/js/bootstrap-colorpicker');?>
    <script>
        $(document).ready(function(){
            <?php
                
                for ($k=0;$k<200;$k++){
                    echo "var carStyle".$k." = $('#".$k."')[0].style;";
                    echo "$('#color".$k."').colorpicker().on('changeColor', function(ev){
                        carStyle".$k.".backgroundColor = ev.color.toHex();
                      }); ";
                }
            ?>
                    
		
        });
    </script>
<?php } ?>

